package com.cat.greedyAlgorithm;

import java.util.Arrays;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/maximum-number-of-coins-you-can-get/?envType=problem-list-v2&envId=GT3MFwwC
 * @create 2025/10/4 09:41
 * @since JDK17
 */

public class Solution52 {
    public int maxCoins(int[] piles) {
        Arrays.sort(piles);
        int ans = 0, n = piles.length;
        for (int i = n - 2; i >= n / 3; i -= 2) {
            ans += piles[i];
        }

        return ans;
    }
}
